//define the product detail
Ext.define('js.app.productos.view.productoDetail', {
	extend: 'framenet.view.frameDetail',

	constructor: function(cfg) {
        var me = this;
        cfg = cfg || {};

        me.callParent([Ext.apply({
            title: 'Product detail',
            items: [{
            	xtype: 'fieldset',
                margin: 10,
                items: [{
                    		name: 'id',
                    		fieldLabel: 'ID',
                    		xtype: 'textfield'
                    	},
                    	{
                    		name: 'nombre',
                    		fieldLabel: 'Nombre',
                    		xtype: 'textfield'
                    	},
                    	{
                    		name: 'descripcion',
                    		fieldLabel: 'Descripcion',
                    		xtype: 'textfield'
                    	},
                    	{
                    		name: 'precio',
                    		fieldLabel: 'Precio',
                    		xtype: 'textfield'
                    	},
                    	{
                    		xtype:'fieldcontainer',
                    	    layout:'hbox',
                    	    items:[{
                    	        	   name: 'codRubro',
                    	        	   fieldLabel: 'Rubro',
                    	        	   xtype: 'textfield'
                    	           },
                    	           {	
                    	        	   xtype: 'button', 
                    	        	   text: '...', 
                    	        	   handler: function() {
                    	        		   Ext.create('framenet.view.frameSearcher', {entity: 'ar.com.framenet.model.Rubro', gridDataModel: 'js.app.productos.model.rubroDataModel', gridColModel: 'js.app.productos.model.rubroGridColModel', handler: this.aftersearch, height: 400, width: 600});                    	        		   
                    	        	   },
                    	        	   aftersearch: function(selectedRecord) {
                    	        		   me.query('textfield[name="codRubro"]')[0].setValue(selectedRecord.get('codRubro'));
                    	        	   }
                    	           }]
                    	},
                    	{
            	    		name: 'codRubro1',
                    		fieldLabel: 'Rubro',
                    		xtype: 'frameCombo',
                    		entity: 'ar.com.framenet.model.Rubro',
                    		valueField: 'codRubro', 
                    		displayField: 'descripcion'                    		
                    	},
                    	{	
         	        	   xtype: 'button', 
         	        	   text: 'Calcular', 
         	        	   handler: function() {
         	        		  Ext.Ajax.request({
         	        		        method: 'GET',
         	        		        url: 'process.htm',
         	        		        params: { className: 'ar.com.framenet.process.Procesadora', a: 0, b: 'abcdefg'},
         	        		        success: function(result, request){
                  	        		   console.info(result);
         	        		        }
         	        		    });
         	        		  
         	        		   var processStore = Ext.create('framenet.store.processStore', {className: 'ar.com.framenet.process.Procesadora'});
         	        		   console.info(processStore);
         	        	   }
         	           }                    	]
            	},
            	{
            		name: 'misc',
            		fieldLabel: 'Misc',
                    xtype: 'tabpanel',
                    plain: true,
                    margin: 10,                    
                    activeTab: 0,
                    items: [{
                        		xtype: 'frameGrid',
                        		title: 'Componentes',
                        		closable: false,
                        		store: Ext.create('framenet.store.gridStore', {model: 'js.app.productos.model.rubroDataModel', entity: 'ar.com.framenet.model.Rubro'}), 
                        		columnModel: 'js.app.productos.model.rubroGridColModel',
                        		editRow: true,
                        		deleteRow: true,
                        		showAddRow: true
                        	},
                        	{
                            	xtype: 'panel',
                            	title: 'Compra'
                        	},
                        	{
                        		xtype: 'panel',
                        		title: 'Venta'
                        	}]
            	}],
            	
        }, cfg)]);
    }
});
